/**
 * 
 */
package com.weblists.commands;

import junit.framework.TestCase;

import com.weblists.CommandFactory;

/**
 * @author Stephen Jennings
 *
 */
public class CommandFactoryTest extends TestCase {

	public void testSingleFactory() {
		CommandFactory factory1 = CommandFactory.getInstance();
		CommandFactory factory2 = CommandFactory.getInstance();
		assertEquals("Wait! I got a different factory!",factory1, factory2);		
	}
	
	public void testFactoryCommands() {
		// Get the factory so we can ask it for command objects.
		CommandFactory factory = CommandFactory.getInstance();
		
		// Make sure the factory gives us a login command. 
		Command loginCmd = factory.getFor("login");		
		assertEquals(LoginCommand.class, loginCmd.getClass());

		// Make sure the factory gives us a signup command.		
		Command signupCmd = factory.getFor("signup");		
		assertEquals(SignUpCommand.class, signupCmd.getClass());

		// Make sure the factory gives us a password command.		
		Command passwordCmd = factory.getFor("password");		
		assertEquals(PasswordCommand.class, passwordCmd.getClass());

		// Make sure the factory gives us a error command.		
		Command errorCmd = factory.getFor("command name we know does not exist");		
		assertEquals(ErrorCommand.class, errorCmd.getClass());
		
		// Check for null command.
		Command nullCmd = factory.getFor(null);
		assertEquals(ErrorCommand.class, nullCmd.getClass());
	}

}
